package form;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import net.miginfocom.swing.MigLayout;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import org.pushingpixels.substance.api.SubstanceLookAndFeel;
import org.pushingpixels.substance.api.skin.SubstanceSaharaLookAndFeel;

public class FormLuanChuyen extends JDialog implements ActionListener {
	
	private JPanel plCenter,plSouth;
	private JTextField txtHangHoa;
	private JTextField txtMaHang;
	private JTextField txtTuKho;
	private JTextField txtDenKho;
	private JTextField txtDonGia;
	private JTextField txtDonVi;
	private JTextField txtSoLuong;
	private JTextField txtThanhTien;
	private JButton btnLuu,btnDong;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		javax.swing.SwingUtilities.invokeLater(new Runnable()
        {
            public void run()
            {
                JFrame.setDefaultLookAndFeelDecorated(true);
                LookAndFeel laf = new SubstanceSaharaLookAndFeel();
                SubstanceLookAndFeel.setToUseConstantThemesOnDialogs(true);
                //UIManager.put(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY,Boolean.TRUE);
                UIManager.put(SubstanceLookAndFeel.SHOW_EXTRA_WIDGETS, Boolean.TRUE);
                JFrame.setDefaultLookAndFeelDecorated(false);
                JDialog.setDefaultLookAndFeelDecorated(true);
                try {
                        UIManager.setLookAndFeel(laf);
                        FormLuanChuyen f = new FormLuanChuyen(null);
    					//frame.setVisible(true);
    					f.setResizable(false);
                } catch (UnsupportedLookAndFeelException e) {
                        e.printStackTrace();
                }
            }
        });		
	}

	/**
	 * Create the frame.
	 */
	public FormLuanChuyen(JFrame frame) {
		super(frame,"Cập nhật kho",true);
		setTitle("Cập nhật kho");
		setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);		
		Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
	    setBounds((screenSize.width-514)/2, (screenSize.height-211)/2, 514, 196);
		//setBounds(100, 100, 514, 211);
		plCenter = new JPanel();
		plCenter.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(plCenter);
		plCenter.setLayout(new MigLayout("", "[][grow][][][grow][][][][grow]", "[][][][][]"));		
		
		JLabel lblMaHang = new JLabel("Mã Hàng");
		plCenter.add(lblMaHang, "cell 0 1,alignx left");
		
		txtMaHang = new JTextField();
		plCenter.add(txtMaHang, "cell 1 1,growx");
		txtMaHang.setColumns(10);
		
		JLabel lblHangHoa = new JLabel("Hàng Hóa");
		plCenter.add(lblHangHoa, "cell 2 1,alignx left");
		
		txtHangHoa = new JTextField();
		plCenter.add(txtHangHoa, "cell 3 1 6 1,growx");
		txtHangHoa.setColumns(10);
		
		JLabel lblTuKho = new JLabel("Từ Kho");
		plCenter.add(lblTuKho, "cell 0 2,alignx left");
		
		txtTuKho = new JTextField();
		plCenter.add(txtTuKho, "cell 1 2 2 1,growx");
		txtTuKho.setColumns(10);
		
		JLabel lblDenKho = new JLabel("Đến Kho");
		plCenter.add(lblDenKho, "cell 3 2,alignx left");
		
		txtDenKho = new JTextField();
		plCenter.add(txtDenKho, "cell 4 2 5 1,growx");
		txtDenKho.setColumns(15);
		
		JLabel lblDonGia = new JLabel("Đơn Giá");
		plCenter.add(lblDonGia, "cell 0 3,alignx left");
		
		txtDonGia = new JTextField();
		plCenter.add(txtDonGia, "cell 1 3 2 1,growx");
		txtDonGia.setColumns(10);
		
		JLabel lblSoLuong = new JLabel("Số Lượng");
		plCenter.add(lblSoLuong, "cell 3 3,alignx left");
		
		txtSoLuong = new JTextField();
		plCenter.add(txtSoLuong, "cell 4 3 5 1,growx");
		txtSoLuong.setColumns(15);
		
		JLabel lblDonVi = new JLabel("Đơn Vị");
		plCenter.add(lblDonVi, "cell 0 4,alignx left");
		
		txtDonVi = new JTextField();
		plCenter.add(txtDonVi, "cell 1 4 2 1,growx");
		txtDonVi.setColumns(10);
		
		JLabel lblThanhTien = new JLabel("Thành Tiền");
		plCenter.add(lblThanhTien, "cell 3 4,alignx left");
		
		txtThanhTien = new JTextField();
		plCenter.add(txtThanhTien, "cell 4 4 5 1,growx");
		txtThanhTien.setColumns(15);
		
		plSouth = new JPanel();
		plCenter.add(plSouth,"cell 4 5 5 1,growx");
		plSouth.setLayout(new FlowLayout(FlowLayout.RIGHT));
		btnLuu = new JButton("Lưu",new ImageIcon("images/luu.gif"));
		btnDong = new JButton("Đóng",new ImageIcon("images/ketthuc.gif"));
		plSouth.add(btnLuu);
		plSouth.add(btnDong);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == btnDong){
			dispose();
		}
		
	}

}
